package utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

import io.PermutationReader;

public class Sorter {
	private DataPair[] l;
	private PermutationReader reader;
	public Sorter(String filename,int quantity) throws FileNotFoundException, IOException{
		l=new DataPair[quantity];
		reader=new PermutationReader(new FileInputStream(new File("sequences/"+filename)));
		String line;
		int i=0;
		while ((line=reader.getNext())!=null){
			StringTokenizer tokenizer=new StringTokenizer(line,",");
			//System.out.println(line);
			DataPair t=new DataPair(tokenizer.nextToken().trim(),Integer.parseInt(tokenizer.nextToken().trim()));
			//System.out.println(t);
			l[i]=t;
			i++;
		}
	}
	public void sort(){		
		Arrays.sort(l);		
	}
	public void printArray(){
		for (int i=0;i<l.length;i++){
			System.out.println(i+" , "+l[i]);
		}
	}
}
